home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
pccp019.zip
/
MASTERM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-28
|
4KB
|
120 lines
#include<stdio.h>
#include<process.h>
main(argc, argv)
int argc;
char **argv;
{
int run;
char stopbstr[2], fpname[256], c;
if(!strcmp(getenv("REMOTE"), "YES"))
{
printf("You appear to be logged in remotely, judging by the environment\n");
printf("variable REMOTE, so this is probably a very bad idea.\n");
printf("Are you sure you want to run MASTERM? (y or n) --> ");
if(getchar()!='y') /* Note getchar() and not getch()! */
{
printf("n\nI didn't think so!\n");
exit(99);
}
else
printf("y\nOK, you're the boss!\n");
}
if((argc!=4)&&(argc!=5))
{
printf("USAGE: masterm <port#> <speed> <databits><parity><stopbits> [<emu file>]\n");
exit(1);
}
spawnlp(P_WAIT, "term", "term", argv[1], argv[2], argv[3], argv[4], NULL);
stopbstr[0]=argv[3][2];
stopbstr[1]='\0';
run=1;
while(run)
{
printf("\n Copyright (C) 1992 Peter Edward Cann, all rights reserved.\n\n");
printf(" UPLOAD: (1) Xmodem (2) Xmodem CRC (3) Xmodem CRC 1K (a) ASCII\n\n");
printf(" DOWNLOAD: (4) Xmodem (5) Xmodem CRC 1K Optional\n\n");
printf(" (t, SPACE or ENTER) Terminal (d) Terminal with Dribble\n\n");
printf(" (q) Quit\n\n ---> ");
c=getch();
printf("%c\n", c);
switch(c)
{
case 'q':
case 'Q':
run=0;
break;
case 't':
case 'T':
case ' ':
case '\r':
if(argc==5)
spawnlp(P_WAIT, "term", "term", argv[1], argv[2], argv[3], argv[4], NULL);
else
spawnlp(P_WAIT, "term", "term", argv[1], argv[2], argv[3], NULL);
break;
case 'd':
case 'D':
printf("Dribble file pathname? (Blank to cancel)\n --> ");
gets(fpname);
if(!strlen(fpname))
break;
if(argc==5)
spawnlp(P_WAIT, "term", "term", argv[1], argv[2], argv[3], argv[4], fpname, NULL);
else
spawnlp(P_WAIT, "term", "term", argv[1], argv[2], argv[3], "-", fpname, NULL);
break;
case '1':
printf("Source file pathname? (Blank to cancel)\n --> ");
gets(fpname);
if(!strlen(fpname))
break;
spawnlp(P_WAIT, "xmodems", "xmodems", argv[1], argv[2], stopbstr, fpname, NULL);
putch('\007');
break;
case 'a':
case 'A':
printf("Source file pathname? (Blank to cancel)\n --> ");
gets(fpname);
if(!strlen(fpname))
break;
spawnlp(P_WAIT, "asciis", "asciis", argv[1], argv[2], argv[3], fpname, NULL);
putch('\007');
break;
case '2':
printf("Source file pathname? (Blank to cancel)\n --> ");
gets(fpname);
if(!strlen(fpname))
break;
spawnlp(P_WAIT, "xmcrcs", "xmcrcs", argv[1], argv[2], stopbstr, fpname, NULL);
putch('\007');
break;
case '3':
printf("Source file pathname? (Blank to cancel)\n --> ");
gets(fpname);
if(!strlen(fpname))
break;
spawnlp(P_WAIT, "xmcrc1ks", "xmcrc1ks", argv[1], argv[2], stopbstr, fpname, NULL);
putch('\007');
break;
case '4':
printf("Target file pathname? (Blank to cancel)\n --> ");
gets(fpname);
if(!strlen(fpname))
break;
spawnlp(P_WAIT, "xmodemr", "xmodemr", argv[1], argv[2], stopbstr, fpname, NULL);
putch('\007');
break;
case '5':
printf("Target file pathname? (Blank to cancel)\n --> ");
gets(fpname);
if(!strlen(fpname))
break;
spawnlp(P_WAIT, "xmcrc1kr", "xmcrc1kr", argv[1], argv[2], stopbstr, fpname, NULL);
putch('\007');
break;
}
}
}